using System;
using System.Collections.Generic;
using EPiServer.Core;
using System.Linq;

namespace EPiServer.Labs.MobilePack.Site
{
    public partial class MobileConnect : MobileBase
    {
        protected PageReference StartingPoint
        {
            get
            {
                if (Request["srcid"] != null) return PageReference.Parse(Request["srcid"]);
                return CurrentPage["StartingPoint"] as PageReference;
            }
        }

        protected int CurrentDepth
        {
            get
            {
                if (Request["Depth"] != null) return int.Parse(Request["Depth"]);
                else return 0;
            }
        }

        protected bool ShowMenu
        {
            get
            {
                return CurrentDepth < ((int)CurrentPage["MaxDepth"]);
            }
        }

        
        protected List<PageData> GetPages()
        {
            return DataFactory.Instance.GetChildren(CurrentPage["StartingPoint"] as PageReference).ToList();
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.DataBind();
        }
    }
}